<?php

namespace app\admin\model;

use think\Model;


class Luyouemp extends Model
{

    

    

    // 表名
    protected $name = 'luyouemp';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'flag_text'
    ];
    

    
    public function getFlagList()
    {
        return ['lyq' => __('Flag lyq'), 'ltgm' => __('Flag ltgm'), 'gdgm' => __('Flag gdgm'), 'fgq' => __('Flag fgq'), 'ydgm' => __('Flag ydgm')];
    }


    public function getFlagTextAttr($value, $data)
    {
        $value = $value ?: ($data['flag'] ?? '');
        $valueArr = explode(',', $value);
        $list = $this->getFlagList();
        return implode(',', array_intersect_key($list, array_flip($valueArr)));
    }

    protected function setFlagAttr($value)
    {
        return is_array($value) ? implode(',', $value) : $value;
    }


}
